package com.nomito.minimito.controller.front;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.nomito.minimito.common.utils.R;
import com.nomito.minimito.entity.ImMsgEntity;
import com.nomito.minimito.service.ImMsgService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author 凌月青缃
 * @date 2021/5/12
 */
@Api(tags = "消息接口")
@RestController
@CrossOrigin
@RequestMapping("/front/message")
public class FMessageController {

    @Autowired
    ImMsgService msgService;
    /**
     * 用户手机端获取未签收的消息列表
     */
    @ApiOperation(value = "用户手机端获取未签收的消息列表")
    @GetMapping("/getUnReadMsgList")
    public R getUnReadMsgList(Long acceptUserId){
        if(StringUtils.isEmpty(acceptUserId)){
            return R.error("接收者ID不能为空");
        }
        //根据接收ID查找未签收的消息列表
        List<ImMsgEntity> unReadMsgList = msgService.list(new QueryWrapper<ImMsgEntity>()
                .eq("accept_user_id",acceptUserId).eq("is_signed",0));
//        List<Long> unReadMsgList = msgService.getUnReadMsgList(acceptUserId);
        return R.ok().setData(unReadMsgList);
    }


    /**
     * 用户签收群聊消息
     */



}
